<template>
  <div id="app">
    <el-container>
      <el-header v-if="show">
        <div class="demo_two">UNI-ADMIN</div>
        <div class="demo_one">
          <el-menu
         
            class="el-menu-demo"
            mode="horizontal"
           
            background-color="#606266"
            text-color="#fff"
            active-text-color="orange"
            router
          >
            <el-menu-item index="/homepage">首页</el-menu-item>
         
            <el-menu-item index="/commodity" >商品</el-menu-item>
            <el-menu-item index="/order">订单</el-menu-item>
            <el-menu-item index="/member">会员</el-menu-item>
            <el-menu-item index="/setup">设置</el-menu-item>
          </el-menu>
        </div>
        <div>
          <el-button type="warning" icon="el-icon-error" circle @click="tuichu"></el-button>
        </div>
      </el-header>
        <router-view/>
      <!-- <el-container> -->
        <!-- <el-aside width="200px">Aside</el-aside>
        <el-main>Main</el-main> -->
        <!-- <router-view></router-view> -->
      <!-- </el-container> -->
    </el-container>
  
  </div>
</template>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
.el-header {
  background-color: #606266;
  color: #333;
  display: inline-flex;
  justify-content: space-between;
  line-height: 60px;
}
.demo_one {
  margin-left: 900px;
}
.demo_two {
  font-size: 20px;
  color: white;
}
</style>
<script>
export default {
  data() {
    return {
      show:true
    }
  },
 watch: {
    $route: {
      handler(newVal, oldVal) {
        console.log(newVal.path);
        // console.log(oldVal);
        if (newVal.path == "/login") {
          this.show = false;
        } else {
          this.show = true;
        }
      },
    },
  },
  methods: {
    tuichu(){
      localStorage.removeItem('token')
      this.$router.push('/login')
    }
  },
}
</script>